package com.my.study.redisson.sub;

import com.my.study.redisson.constant.TaskConstants;
import com.my.study.redisson.listener.ClientRestListener;
import com.my.study.redisson.model.Message;
import org.redisson.api.RTopic;
import org.redisson.api.RedissonClient;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 注册redis channel监听器
 * 
 * @author: yidujun
 * @create: 2021/11/08 16:26
 */
@Component
public class SubscribeRestThread extends Thread {

    @Resource
    RedissonClient redissonClient;

    @Resource
    ClientRestListener clientRestListener;

    @Override
    public void run() {
        RTopic topic = redissonClient.getTopic(TaskConstants.CHANNEL_SERVER_REST);
        topic.addListener(Message.class, clientRestListener);
    }
}
